home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / ISDNIF.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  15KB  |  389 lines

  1. /* X25 changes:
  2.    Added constants ISDN_PROTO_L2_X25DTE/DCE and corresponding ISDN_FEATURE_..
  3.    */
  4.  
  5. /* $Id: isdnif.h,v 1.23 1998/02/20 17:36:52 fritz Exp $
  6.  *
  7.  * Linux ISDN subsystem
  8.  *
  9.  * Definition of the interface between the subsystem and its low-level drivers.
  10.  *
  11.  * Copyright 1994,95,96 by Fritz Elfert (fritz@wuemaus.franken.de)
  12.  * Copyright 1995,96    Thinking Objects Software GmbH Wuerzburg
  13.  * 
  14.  * This program is free software; you can redistribute it and/or modify
  15.  * it under the terms of the GNU General Public License as published by
  16.  * the Free Software Foundation; either version 2, or (at your option)
  17.  * any later version.
  18.  *
  19.  * This program is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  * GNU General Public License for more details.
  23.  *
  24.  * You should have received a copy of the GNU General Public License
  25.  * along with this program; if not, write to the Free Software
  26.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  27.  *
  28.  * $Log: isdnif.h,v $
  29.  * Revision 1.23  1998/02/20 17:36:52  fritz
  30.  * Added L2-protocols for V.110, changed FEATURE-Flag-constants.
  31.  *
  32.  * Revision 1.22  1998/01/31 22:14:12  keil
  33.  * changes for 2.1.82
  34.  *
  35.  * Revision 1.21  1997/10/09 21:28:13  fritz
  36.  * New HL<->LL interface:
  37.  *   New BSENT callback with nr. of bytes included.
  38.  *   Sending without ACK.
  39.  *   New L1 error status (not yet in use).
  40.  *   Cleaned up obsolete structures.
  41.  * Implemented Cisco-SLARP.
  42.  * Changed local net-interface data to be dynamically allocated.
  43.  * Removed old 2.0 compatibility stuff.
  44.  *
  45.  * Revision 1.20  1997/05/27 15:18:06  fritz
  46.  * Added changes for recent 2.1.x kernels:
  47.  *   changed return type of isdn_close
  48.  *   queue_task_* -> queue_task
  49.  *   clear/set_bit -> test_and_... where apropriate.
  50.  *   changed type of hard_header_cache parameter.
  51.  *
  52.  * Revision 1.19  1997/03/25 23:13:56  keil
  53.  * NI-1 US protocol
  54.  *
  55.  * Revision 1.18  1997/03/04 22:09:18  calle
  56.  * Change macros copy_from_user and copy_to_user in inline function.
  57.  * These are now correct replacements of the functions for 2.1.xx
  58.  *
  59.  * Revision 1.17  1997/02/10 21:12:53  fritz
  60.  * More setup-interface changes.
  61.  *
  62.  * Revision 1.16  1997/02/10 19:42:57  fritz
  63.  * New interface for reporting incoming calls.
  64.  *
  65.  * Revision 1.15  1997/02/09 00:18:42  keil
  66.  * leased line support
  67.  *
  68.  * Revision 1.14  1997/02/03 23:43:00  fritz
  69.  * Misc changes for Kernel 2.1.X compatibility.
  70.  *
  71.  * Revision 1.13  1996/11/13 02:39:59  fritz
  72.  * More compatibility changes.
  73.  *
  74.  * Revision 1.12  1996/11/06 17:38:48  keil
  75.  * more changes for 2.1.X
  76.  *
  77.  * Revision 1.11  1996/10/23 11:59:42  fritz
  78.  * More compatibility changes.
  79.  *
  80.  * Revision 1.10  1996/10/22 23:14:19  fritz
  81.  * Changes for compatibility to 2.0.X and 2.1.X kernels.
  82.  *
  83.  * Revision 1.9  1996/06/06 21:24:24  fritz
  84.  * Started adding support for suspend/resume.
  85.  *
  86.  * Revision 1.8  1996/05/18 01:45:37  fritz
  87.  * More spelling corrections.
  88.  *
  89.  * Revision 1.7  1996/05/18 01:37:19  fritz
  90.  * Added spelling corrections and some minor changes
  91.  * to stay in sync with kernel.
  92.  *
  93.  * Revision 1.6  1996/05/17 03:59:28  fritz
  94.  * Marked rcvcallb and writebuf obsolete.
  95.  *
  96.  * Revision 1.5  1996/05/01 11:43:54  fritz
  97.  * Removed STANDALONE
  98.  *
  99.  * Revision 1.4  1996/05/01 11:38:40  fritz
  100.  * Added ISDN_FEATURE_L2_TRANS
  101.  *
  102.  * Revision 1.3  1996/04/29 22:57:54  fritz
  103.  * Added driverId and channel parameters to
  104.  * writecmd() and readstat().
  105.  * Added constant for voice-support.
  106.  *
  107.  * Revision 1.2  1996/04/20 17:02:40  fritz
  108.  * Changes to support skbuffs for Lowlevel-Drivers.
  109.  * Misc. typos
  110.  *
  111.  * Revision 1.1  1996/01/09 05:50:51  fritz
  112.  * Initial revision
  113.  *
  114.  */
  115.  
  116. #ifndef isdnif_h
  117. #define isdnif_h
  118.  
  119. /*
  120.  * Values for general protocol-selection
  121.  */
  122. #define ISDN_PTYPE_UNKNOWN   0   /* Protocol undefined   */
  123. #define ISDN_PTYPE_1TR6      1   /* german 1TR6-protocol */
  124. #define ISDN_PTYPE_EURO      2   /* EDSS1-protocol       */
  125. #define ISDN_PTYPE_LEASED    3   /* for leased lines     */
  126. #define ISDN_PTYPE_NI1       4   /* US NI-1 protocol     */
  127. #define ISDN_PTYPE_MAX       7   /* Max. 8 Protocols     */
  128.  
  129. /*
  130.  * Values for Layer-2-protocol-selection
  131.  */
  132. #define ISDN_PROTO_L2_X75I   0   /* X75/LAPB with I-Frames            */
  133. #define ISDN_PROTO_L2_X75UI  1   /* X75/LAPB with UI-Frames           */
  134. #define ISDN_PROTO_L2_X75BUI 2   /* X75/LAPB with UI-Frames           */
  135. #define ISDN_PROTO_L2_HDLC   3   /* HDLC                              */
  136. #define ISDN_PROTO_L2_TRANS  4   /* Transparent (Voice)               */
  137. #define ISDN_PROTO_L2_X25DTE 5   /* X25/LAPB DTE mode                 */
  138. #define ISDN_PROTO_L2_X25DCE 6   /* X25/LAPB DCE mode                 */
  139. #define ISDN_PROTO_L2_V11096 7   /* V.110 bitrate adaption 9600 Baud  */
  140. #define ISDN_PROTO_L2_V11019 8   /* V.110 bitrate adaption 19200 Baud */
  141. #define ISDN_PROTO_L2_V11038 9   /* V.110 bitrate adaption 38400 Baud */
  142. #define ISDN_PROTO_L2_MAX    15  /* Max. 16 Protocols                 */
  143.  
  144. /*
  145.  * Values for Layer-3-protocol-selection
  146.  */
  147. #define ISDN_PROTO_L3_TRANS  0   /* Transparent                 */
  148. #define ISDN_PROTO_L3_MAX    7   /* Max. 8 Protocols            */
  149.  
  150. #ifdef __KERNEL__
  151.  
  152. #include <linux/skbuff.h>
  153.  
  154. /*
  155.  * Commands from linklevel to lowlevel
  156.  *
  157.  */
  158. #define ISDN_CMD_IOCTL    0       /* Perform ioctl                         */
  159. #define ISDN_CMD_DIAL     1       /* Dial out                              */
  160. #define ISDN_CMD_ACCEPTD  2       /* Accept an incoming call on D-Chan.    */
  161. #define ISDN_CMD_ACCEPTB  3       /* Request B-Channel connect.            */
  162. #define ISDN_CMD_HANGUP   4       /* Hangup                                */
  163. #define ISDN_CMD_CLREAZ   5       /* Clear EAZ(s) of channel               */
  164. #define ISDN_CMD_SETEAZ   6       /* Set EAZ(s) of channel                 */
  165. #define ISDN_CMD_GETEAZ   7       /* Get EAZ(s) of channel                 */
  166. #define ISDN_CMD_SETSIL   8       /* Set Service-Indicator-List of channel */
  167. #define ISDN_CMD_GETSIL   9       /* Get Service-Indicator-List of channel */
  168. #define ISDN_CMD_SETL2   10       /* Set B-Chan. Layer2-Parameter          */
  169. #define ISDN_CMD_GETL2   11       /* Get B-Chan. Layer2-Parameter          */
  170. #define ISDN_CMD_SETL3   12       /* Set B-Chan. Layer3-Parameter          */
  171. #define ISDN_CMD_GETL3   13       /* Get B-Chan. Layer3-Parameter          */
  172. #define ISDN_CMD_LOCK    14       /* Signal usage by upper levels          */
  173. #define ISDN_CMD_UNLOCK  15       /* Release usage-lock                    */
  174. #define ISDN_CMD_SUSPEND 16       /* Suspend connection                    */
  175. #define ISDN_CMD_RESUME  17       /* Resume connection                     */
  176.  
  177. /*
  178.  * Status-Values delivered from lowlevel to linklevel via
  179.  * statcallb().
  180.  *
  181.  */
  182. #define ISDN_STAT_STAVAIL 256    /* Raw status-data available             */
  183. #define ISDN_STAT_ICALL   257    /* Incoming call detected                */
  184. #define ISDN_STAT_RUN     258    /* Signal protocol-code is running       */
  185. #define ISDN_STAT_STOP    259    /* Signal halt of protocol-code          */
  186. #define ISDN_STAT_DCONN   260    /* Signal D-Channel connect              */
  187. #define ISDN_STAT_BCONN   261    /* Signal B-Channel connect              */
  188. #define ISDN_STAT_DHUP    262    /* Signal D-Channel disconnect           */
  189. #define ISDN_STAT_BHUP    263    /* Signal B-Channel disconnect           */
  190. #define ISDN_STAT_CINF    264    /* Charge-Info                           */
  191. #define ISDN_STAT_LOAD    265    /* Signal new lowlevel-driver is loaded  */
  192. #define ISDN_STAT_UNLOAD  266    /* Signal unload of lowlevel-driver      */
  193. #define ISDN_STAT_BSENT   267    /* Signal packet sent                    */
  194. #define ISDN_STAT_NODCH   268    /* Signal no D-Channel                   */
  195. #define ISDN_STAT_ADDCH   269    /* Add more Channels                     */
  196. #define ISDN_STAT_CAUSE   270    /* Cause-Message                         */
  197. #define ISDN_STAT_L1ERR   271    /* Signal Layer-1 Error                  */
  198.  
  199. /*
  200.  * Values for errcode field
  201.  */
  202. #define ISDN_STAT_L1ERR_SEND 1
  203. #define ISDN_STAT_L1ERR_RECV 2
  204.  
  205. /*
  206.  * Values for feature-field of interface-struct.
  207.  */
  208. /* Layer 2 */
  209. #define ISDN_FEATURE_L2_X75I    (0x0001 << ISDN_PROTO_L2_X75I)
  210. #define ISDN_FEATURE_L2_X75UI   (0x0001 << ISDN_PROTO_L2_X75UI)
  211. #define ISDN_FEATURE_L2_X75BUI  (0x0001 << ISDN_PROTO_L2_X75BUI)
  212. #define ISDN_FEATURE_L2_HDLC    (0x0001 << ISDN_PROTO_L2_HDLC)
  213. #define ISDN_FEATURE_L2_TRANS   (0x0001 << ISDN_PROTO_L2_TRANS)
  214. #define ISDN_FEATURE_L2_X25DTE  (0x0001 << ISDN_PROTO_L2_X25DTE)
  215. #define ISDN_FEATURE_L2_X25DCE  (0x0001 << ISDN_PROTO_L2_X25DCE)
  216. #define ISDN_FEATURE_L2_V11096  (0x0001 << ISDN_PROTO_L2_V11096)
  217. #define ISDN_FEATURE_L2_V11019  (0x0001 << ISDN_PROTO_L2_V11019)
  218. #define ISDN_FEATURE_L2_V11038  (0x0001 << ISDN_PROTO_L2_V11038)
  219.  
  220. #define ISDN_FEATURE_L2_MASK    (0x0FFFF) /* Max. 16 protocols */
  221. #define ISDN_FEATURE_L2_SHIFT   (0)
  222.  
  223. /* Layer 3 */
  224. #define ISDN_FEATURE_L3_TRANS   (0x10000 << ISDN_PROTO_L3_TRANS)
  225.  
  226. #define ISDN_FEATURE_L3_MASK    (0x0FF0000) /* Max. 8 Protocols */
  227. #define ISDN_FEATURE_L3_SHIFT   (16)
  228.  
  229. /* Signaling */
  230. #define ISDN_FEATURE_P_UNKNOWN  (0x1000000 << ISDN_PTYPE_UNKNOWN)
  231. #define ISDN_FEATURE_P_1TR6     (0x1000000 << ISDN_PTYPE_1TR6)
  232. #define ISDN_FEATURE_P_EURO     (0x1000000 << ISDN_PTYPE_EURO)
  233. #define ISDN_FEATURE_P_NI1      (0x1000000 << ISDN_PTYPE_NI1)
  234.  
  235. #define ISDN_FEATURE_P_MASK     (0x0FF000000) /* Max. 8 Protocols */
  236. #define ISDN_FEATURE_P_SHIFT    (24)
  237.  
  238. typedef struct setup_parm {
  239.     char phone[32];         /* Remote Phone-Number */
  240.     char eazmsn[32];        /* Local EAZ or MSN    */
  241.     unsigned char si1;      /* Service Indicator 1 */
  242.     unsigned char si2;      /* Service Indicator 2 */
  243.     unsigned char plan;     /* Numbering plan      */
  244.     unsigned char screen;   /* Screening info      */
  245. } setup_parm;
  246.  
  247. /*
  248.  * Structure for exchanging above infos
  249.  *
  250.  */
  251. typedef struct {
  252.   int   driver;                  /* Lowlevel-Driver-ID                    */
  253.   int   command;                 /* Command or Status (see above)         */
  254.   ulong arg;                     /* Additional Data                       */
  255.   union {
  256.     ulong errcode;               /* Type of error with STAT_L1ERR         */
  257.     int   length;                /* Amount of bytes sent with STAT_BSENT  */
  258.     char  num[50];               /* Additional Data                       */
  259.     setup_parm setup;
  260.   } parm;
  261. } isdn_ctrl;
  262.  
  263. /*
  264.  * The interface-struct itself (initialized at load-time of lowlevel-driver)
  265.  *
  266.  * See Documentation/isdn/INTERFACE for a description, how the communication
  267.  * between the ISDN subsystem and its drivers is done.
  268.  *
  269.  */
  270. typedef struct {
  271.   /* Number of channels supported by this driver
  272.    */
  273.   int channels;
  274.  
  275.   /* 
  276.    * Maximum Size of transmit/receive-buffer this driver supports.
  277.    */
  278.   int maxbufsize;
  279.  
  280.   /* Feature-Flags for this driver.
  281.    * See defines ISDN_FEATURE_... for Values
  282.    */
  283.   unsigned long features;
  284.  
  285.   /*
  286.    * Needed for calculating
  287.    * dev->hard_header_len = linklayer header + hl_hdrlen;
  288.    * Drivers, not supporting sk_buff's should set this to 0.
  289.    */
  290.   unsigned short hl_hdrlen;
  291.  
  292.   /*
  293.    * Receive-Callback using sk_buff's
  294.    * Parameters:
  295.    *             int                    Driver-ID
  296.    *             int                    local channel-number (0 ...)
  297.    *             struct sk_buff *skb    received Data
  298.    */
  299.   void (*rcvcallb_skb)(int, int, struct sk_buff *);
  300.  
  301.   /* Status-Callback
  302.    * Parameters:
  303.    *             isdn_ctrl*
  304.    *                   driver  = Driver ID.
  305.    *                   command = One of above ISDN_STAT_... constants.
  306.    *                   arg     = depending on status-type.
  307.    *                   num     = depending on status-type.
  308.    */
  309.   int (*statcallb)(isdn_ctrl*);
  310.  
  311.   /* Send command
  312.    * Parameters:
  313.    *             isdn_ctrl*
  314.    *                   driver  = Driver ID.
  315.    *                   command = One of above ISDN_CMD_... constants.
  316.    *                   arg     = depending on command.
  317.    *                   num     = depending on command.
  318.    */
  319.   int (*command)(isdn_ctrl*);
  320.  
  321.   /*
  322.    * Send data using sk_buff's
  323.    * Parameters:
  324.    *             int                    driverId
  325.    *             int                    local channel-number (0...)
  326.    *             int                    Flag: Need ACK for this packet.
  327.    *             struct sk_buff *skb    Data to send
  328.    */
  329.   int (*writebuf_skb) (int, int, int, struct sk_buff *);
  330.  
  331.   /* Send raw D-Channel-Commands
  332.    * Parameters:
  333.    *             u_char pointer data
  334.    *             int    length of data
  335.    *             int    Flag: 0 = Call form Kernel-Space (use memcpy,
  336.    *                              no schedule allowed) 
  337.    *                          1 = Data is in User-Space (use memcpy_fromfs,
  338.    *                              may schedule)
  339.    *             int    driverId
  340.    *             int    local channel-number (0 ...)
  341.    */
  342.   int (*writecmd)(const u_char*, int, int, int, int);
  343.  
  344.   /* Read raw Status replies
  345.    *             u_char pointer data (volatile)
  346.    *             int    length of buffer
  347.    *             int    Flag: 0 = Call form Kernel-Space (use memcpy,
  348.    *                              no schedule allowed) 
  349.    *                          1 = Data is in User-Space (use memcpy_fromfs,
  350.    *                              may schedule)
  351.    *             int    driverId
  352.    *             int    local channel-number (0 ...)
  353.    */
  354.   int (*readstat)(u_char*, int, int, int, int);
  355.  
  356.   char id[20];
  357. } isdn_if;
  358.  
  359. /*
  360.  * Function which must be called by lowlevel-driver at loadtime with
  361.  * the following fields of above struct set:
  362.  *
  363.  * channels     Number of channels that will be supported.
  364.  * hl_hdrlen    Space to preserve in sk_buff's when sending. Drivers, not
  365.  *              supporting sk_buff's should set this to 0.
  366.  * command      Address of Command-Handler.
  367.  * features     Bitwise coded Features of this driver. (use ISDN_FEATURE_...)
  368.  * writebuf_skb Address of Skbuff-Send-Handler.
  369.  * writecmd        "    "  D-Channel  " which accepts raw D-Ch-Commands.
  370.  * readstat        "    "  D-Channel  " which delivers raw Status-Data.
  371.  *
  372.  * The linklevel-driver fills the following fields:
  373.  *
  374.  * channels      Driver-ID assigned to this driver. (Must be used on all
  375.  *               subsequent callbacks.
  376.  * rcvcallb_skb  Address of handler for received Skbuff's.
  377.  * statcallb        "    "     "    for status-changes.
  378.  *
  379.  */
  380. extern int register_isdn(isdn_if*);
  381.  
  382. #ifndef LINUX_VERSION_CODE
  383. #include <linux/version.h>
  384. #endif
  385. #include <asm/uaccess.h>
  386.  
  387. #endif /* __KERNEL__ */
  388. #endif /* isdnif_h */
  389.